package com.lysj.food.food.service;

import com.lysj.admin.utils.constant.CommonConstant;
import com.lysj.admin.utils.exception.BaseException;
import com.lysj.admin.utils.spring.foundation.base.BaseService;
import com.lysj.admin.utils.web.ParamUtil;
import com.lysj.food.food.domain.FoodAttribute;
import com.lysj.food.food.domain.FoodAttributeDetail;
import com.lysj.food.food.repository.FoodAttributeDetailRepository;
import com.lysj.food.food.repository.FoodAttributeRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Created by wtl on 2019-03-19 16:00:45
 * @description 菜品属性详情服务层
 */
@Slf4j
@Service
@Transactional
public class FoodAttributeDetailService implements BaseService<FoodAttributeDetail> {

    @Resource
    private FoodAttributeDetailRepository foodAttributeDetailRepository;

    @Override
    public FoodAttributeDetailRepository getRepository() {
        return foodAttributeDetailRepository;
    }

    // 多规格单位id,name
    public Map<String, String> map(String storeId) {

        Map<String, String> map = new HashMap<>();
        List<FoodAttributeDetail> foodAttributeDetails = foodAttributeDetailRepository.findByStoreIdAndDelFlag(storeId, CommonConstant.NORMAL_FLAG);
        for (FoodAttributeDetail foodAttributeDetail : foodAttributeDetails) {
            map.put(foodAttributeDetail.getId(), foodAttributeDetail.getName());
        }
        return map;
    }


}